package physics;

public class Vector {
	public double x;
	public double y;
	
	public Vector(double d, double e) {
		this.x = d;
		this.y = e;
	}

	public Vector() {
		this.x = 0;
		this.y = 0;
	}

	public double getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}
	
	public double dot(Vector other) {
		return (this.x * other.x) + (this.y * other.y); 
	}
	
	public Vector multiply(Vector other) {
		return new Vector(this.x * other.x, this.y * other.y);
	}
	
	public Vector multiply(double scalar) {
		return new Vector(this.x * scalar, this.y * scalar);
	}
	
	public Vector add(Vector other) {
		return new Vector(this.x + other.x, this.y + other.y);
	}
	
	public Vector normalize() {
		double magnitude = Math.sqrt(this.x * this.x + this.y * this.y);
		return new Vector(this.x / magnitude, this.y / magnitude);
	}
	
	public boolean equals(Object other) {
		if(!(other instanceof Vector)) {
			return false;
		}
		return this.x == ((Vector)other).x && this.y == ((Vector)other).y;
	}
	
	public String toString() {
		return "(" + x + ", " + y + ")";
	}
}
